package com.bigtotoro.shuiyincamera.editimage.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bigtotoro.shuiyincamera.R;
import com.bigtotoro.shuiyincamera.editimage.EditImageActivity;
import com.bigtotoro.shuiyincamera.editimage.ModuleConfig;


/**
 * 批量加水印
 */
public class MountWaterMarkFragment extends BaseEditFragment implements View.OnClickListener {
    public static final int INDEX = ModuleConfig.INDEX_MAIN;
    private static EditImageActivity mEditImageActivity;
    public static final String TAG = MountWaterMarkFragment.class.getName();
    private View mainView;

//    private View stickerBtn;  //贴图按钮
    private View mTextBtn;  //添加文字按钮
    private View mImageBtn;  //图片水印按钮
    //共有三个画布，分别是mStickerFragment贴图画布，mAddTextFragment文字画布，mImageStickerFragment
    // 图片画布
    //先囊括所有画布，然后点击底部菜单时，分别显示对应的画布和执行对应的初始化操作
    //如果要批量添加，需要把三个画布fragment对应的功能整合在一起，载入图片和显示画布，
    //1.载入图片(肯定要的)，载入时最好将图片铺满屏幕

    public static MountWaterMarkFragment newInstance(EditImageActivity activity) {
        MountWaterMarkFragment fragment = new MountWaterMarkFragment();
        mEditImageActivity = activity;
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mainView = inflater.inflate(R.layout.fragment_mount_water_mark,
                null);
        return mainView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

//        stickerBtn = mainView.findViewById(R.id.btn_stickers);// 表情水印
        mTextBtn = mainView.findViewById(R.id.btn_text);// 文字水印
        mImageBtn = mainView.findViewById(R.id.btn_picture);// 图片水印

//        stickerBtn.setOnClickListener(this);
        mTextBtn.setOnClickListener(this);
        mImageBtn.setOnClickListener(this);
    }

    @Override
    public void onShow() {

    }

    @Override
    public void onShow(EditImageActivity activity) {

    }

    @Override
    public void onShowNoNextMenu(EditImageActivity activity) {

    }

    @Override
    public void backToMain() {

    }

    @Override
    public void onClick(View v) {
//        if (v == stickerBtn) {
//            onStickClick();
//        }else
            if (v == mTextBtn) {
            onAddTextClick();
        }
        else if (v == mImageBtn) {
            onPictureClick();
        }
    }

    /**
     * 贴图模式
     *
     * @author panyi
     */
    private void onStickClick() {
        activity.bottomGallery.setCurrentItem(StickerFragment.INDEX);
        activity.mStickerFragment.onShow();
    }

    /**
     * 插入文字模式
     *
     * @author panyi
     */
    private void onAddTextClick() {
        activity.bottomGallery.setCurrentItem(MountAddTextFragment.INDEX);
        activity.mMountAddTextFragment.onShow();
    }

    /**
     * 自由绘制模式
     */
    private void onPictureClick() {
        //不切换菜单，直接进入选择图片界面
        activity.bottomGallery.setCurrentItem(MountImageStickerFragment.INDEX); //底部菜单切换
        activity.mMountImageStickerFragment.onShow();
    }


}
